<?php
/**
 * Created by PhpStorm.
 * User: 清行
 * Date: 2019/3/21
 * Time: 13:50
 */

namespace xiaokang;


class Register
{

    protected static $object;
    protected static $tree = array();

    static function offsetGet($key)
    {
        if (empty(static::$tree[$key]))
        {
            static::$tree[$key] = $key();
        }
        return static::$tree[$key];
    }

    static function offsetSet($key, $value)
    {
        if (empty(static::$tree[$key]))
        {
            static::$tree[$key] = new $value;
        }
        return static::$tree[$key];
    }

    static function offsetExists($key)
    {
        return isset(static::$tree[$key]);
    }

    static function offsetUnset($key)
    {
        unset(static::$tree[$key]);
    }
}